package com.cskaoyan.mall.controller.admin;

import com.cskaoyan.mall.bean.Keyword;
import com.cskaoyan.mall.bean.bo.KeywordListBO;
import com.cskaoyan.mall.bean.vo.GeneralItemsBean;
import com.cskaoyan.mall.bean.vo.ResultVO;
import com.cskaoyan.mall.service.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: dyj
 * @Date: 2021/1/11 9:33
 * @Description 商场管理 关键字模块
 */
@RestController
@RequestMapping("/admin/keyword")
public class KeywordController {

    @Autowired
    KeywordService keywordService;

    @RequestMapping("list")
    public ResultVO list(KeywordListBO keywordListBO){
        GeneralItemsBean itemsBean = keywordService.SelectListByPageLimit(keywordListBO);
        return ResultVO.ok(itemsBean);
    }

    @RequestMapping("create")
    public ResultVO create(@RequestBody Keyword keyword){
        keywordService.insertKeyword(keyword);
        return ResultVO.ok(keyword);
    }

    @RequestMapping("update")
    public ResultVO update(@RequestBody Keyword keyword){
        keywordService.updateKeyWordSelective(keyword);
        return ResultVO.ok(keyword);
    }

    @RequestMapping("delete")
    public ResultVO delete(@RequestBody Keyword keyword){
        keywordService.deleteKeywordById(keyword.getId());
        return ResultVO.ok();
    }
}
